package com.leonzhangxf.guice.bill;


import com.leonzhangxf.guice.bill.domain.ChargeResult;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * A database transaction log implement. Would write transaction log to
 * database.
 *
 * @author leonzhangxf
 */
@Singleton
public class DatabaseTransactionLog implements TransactionLog {

    private String jdbcUrl;

    private int threadPoolSize;

    @Inject
    public DatabaseTransactionLog(String jdbcUrl) {
        this.jdbcUrl = jdbcUrl;
    }

    @Override
    public void logChargeResult(ChargeResult result) {
        System.out.println(result);
        System.out.println(jdbcUrl + " : " + threadPoolSize);
    }

    @Override
    public void logConnectException(UnreachableException e) {
        System.out.println(e.getMessage());
    }

    public void setThreadPoolSize(int threadPoolSize) {
        this.threadPoolSize = threadPoolSize;
    }
}
